

use "$clean/clean_all.dta", clear	
	
loc experiments "canvass_any_main_unres  days_unres_main doors_unres_main_wins"
		   
		   
preserve

clear all
eststo clear
estimates drop _all

set obs 10
qui gen x = 1
qui gen y = 1

loc columns = 0

foreach choice in `experiments' `experiments'  {

    loc ++columns
    qui eststo col`columns': reg x y

}

restore


/* Statistics */

loc colnum = 1
loc colnames ""


foreach choice in `experiments' {

/* Statistics */

	
	reg `choice' i.treatment##i.comp_overstimate , vce(r)
	estadd loc thisstat15 = `e(N)': col`colnum' 

	sigstar_lincom 1.treatment , prec(3)  bstar


	sigstar_lincom 1.treatment , prec(3)  bstar
	estadd loc thisstat2 = "`r(bstar)'": col`colnum'
    estadd loc thisstat3 = "`r(sestar)'": col`colnum'
	
	
	sigstar_lincom 1.comp_overstimate  , prec(3)  bstar
	estadd loc thisstat5 = "`r(bstar)'": col`colnum'
    estadd loc thisstat6 = "`r(sestar)'": col`colnum'
	
	sigstar_lincom 1.treatment#1.comp_overstimate , prec(3)  bstar
    estadd loc thisstat8 = "`r(bstar)'": col`colnum'
    estadd loc thisstat9 = "`r(sestar)'": col`colnum'
	
	
	sigstar_lincom 1.treatment+ 1.treatment#1.comp_overstimate , prec(3)  bstar
	estadd local thisstat12 "`r(bstar)'" : col`colnum'
	estadd local thisstat13  "`r(sestar)'" : col`colnum'
	

	qui sum `choice'  if treatment==0 
    estadd scalar thisstat14 = r(mean): col`colnum'
	estadd local thisstat16 = "No" : col`colnum'
		
	
	
    loc ++colnum
    loc colnames "`colnames' `"`: var la `choice''"'"
	
	reg `choice' i.treatment##i.comp_overstimate $contr, vce(r)
	estadd loc thisstat15 = `e(N)': col`colnum' 

	cap qui do "$do/sigstar_lincom.do" 
	sigstar_lincom 1.treatment , prec(3)  bstar
	estadd loc thisstat2 = "`r(bstar)'": col`colnum'
    estadd loc thisstat3 = "`r(sestar)'": col`colnum'
	
	
	sigstar_lincom 1.comp_overstimate  , prec(3)  bstar
	estadd loc thisstat5 = "`r(bstar)'": col`colnum'
    estadd loc thisstat6 = "`r(sestar)'": col`colnum'
	
	sigstar_lincom 1.treatment#1.comp_overstimate , prec(3)  bstar
    estadd loc thisstat8 = "`r(bstar)'": col`colnum'
    estadd loc thisstat9 = "`r(sestar)'": col`colnum'
	
	
	sigstar_lincom 1.treatment+ 1.treatment#1.comp_overstimate , prec(3)  bstar
	estadd local thisstat12 "`r(bstar)'" : col`colnum'
	estadd local thisstat13 "`r(sestar)'" : col`colnum'
	

	qui sum `choice'  if treatment==0 
    estadd scalar thisstat14 = r(mean): col`colnum'
	estadd local thisstat16 = "Yes" : col`colnum'
	
	
    loc ++colnum
    loc colnames "`colnames' `"`: var la `choice''"'"
	

	}
	

	

loc rowlabels "" "   "Treatment" " " " " "Over-estimator" " " " " "Treatment $\times$ Over-estimator" " " " "  "\midrule  ""Effect on over-estimator" " "  "\midrule Control mean" "Observations" "\midrule Controls" "
loc rowstats ""

forval i = 1/16 {
    loc rowstats "`rowstats' thisstat`i'"
}

esttab * using "$tables/Table_A8.tex", replace cells(none) booktabs nonotes nonum compress alignment(c) ///
nogap noobs nobaselevels label stats(`rowstats', labels(`rowlabels') ///
  fmt( 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 0  )) nomtitles ///
 mgroups( "Any canvassing" "Days canvassed" "Door knocked",  pattern(1 0 1 0 1 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))
